#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

int e, node[ 200001 ], cost[ 200001 ], dis[ 200001 ], next[ 200001 ], head[ 200001 ];
queue<int> q;
int d[ 1001 ], c[ 1001 ];

void addedge( int u, int v, int w1, int w2 )
{
    node[ e ] = v; dis[ e ] = w1; cost[ e ] = w2; next[ e ] = head[ u ]; head[ u ] = e++;
}

int main( )
{
    int n, m, i, u, v, w1, w2, s, t;
    while ( scanf("%d%d", &n, &m) )
    {
        if ( n == 0 && m == 0 ) break;
        memset( head, -1, sizeof( head ) );
        e = 0;
        for ( i = 0; i < m; i++ )
        {
            scanf("%d%d%d%d", &u, &v, &w1, &w2);
            addedge( u, v, w1, w2 );
            addedge( v, u, w1, w2 );
        }
        memset( d, 0x3f, sizeof( d ) );
        memset( c, 0x3f, sizeof( c ) );
        scanf("%d%d", &s, &t);
        d[ s ] = c[ s ] = 0;
        q.push( s );
        while ( !q.empty( ) )
        {
            u = q.front( );
            q.pop( );
            for ( i = head[ u ]; i != -1; i = next[ i ] )
            {
                v = node[ i ];
                w1 = dis[ i ];
                w2 = cost[ i ];
                if ( d[ v ] > d[ u ] + w1 || d[ v ] == d[ u ] + w1 && c[ v ] > c[ u ] + w2 )
                {
                    d[ v ] = d[ u ] + w1;
                    c[ v ] = c[ u ] + w2;
                    q.push( v );
                }
            }
        }
        printf("%d %d\n", d[ t ], c[ t ]);
    }
    return 0;
}
